package com.hen.web.henweb.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 狠穿
 * @version 1.0.0
 * @date 2023/4/6
 * @function 登录拦截器
 */
@Slf4j
public class UserLoginCheckInterceptor implements HandlerInterceptor {
    //@Override
    //public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
    //    List<Cookie> cookies = Arrays.asList(request.getCookies());
    //    log.info("进行登录拦截校验");
    //    boolean jessionid = cookies.stream().map(cookie -> cookie.getName()).collect(Collectors.toList()).contains("JESSIONID");
    //    if( !jessionid ){
    //        log.info("尚未登录，自动跳转到登录页面");
    //        response.sendRedirect("/user/login");
    //        return false;
    //    }
    //    return true;
    //}
}
